/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: Faculty of informatics, Burapha University 01
 * License Type: Purchased
 */
package cn.imvc.app.entities;

import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="goods_class")
public class GoodsClass implements Serializable {
	public GoodsClass() {
	}
	
	private int id;
	
	private String name;
	
	private String image;
	
	private cn.imvc.app.entities.GoodsClass parent;
	
	private Byte isShow;
	
	private Integer sort;
	
	private java.util.Set goods = new java.util.HashSet();
	
	private java.util.Set goodsClass = new java.util.HashSet();
	
	private java.util.Set goodsClassAttr = new java.util.HashSet();
	
	private java.util.Set brand_Goods_Class = new java.util.HashSet();
	
	public void setId(int value) {
		this.id = value;
	}
	
	@Column(name="id", nullable=false)	
	@Id	
	@GeneratedValue(generator="CN_IMVC_APP_ENTITIES_GOODSCLASS_ID_GENERATOR")	
	@org.hibernate.annotations.GenericGenerator(name="CN_IMVC_APP_ENTITIES_GOODSCLASS_ID_GENERATOR", strategy="identity")	
	public int getId() {
		return id;
	}
	
	@Transient	
	public int getORMID() {
		return getId();
	}
	
	/**
	 * 分类名称
	 */
	public void setName(String value) {
		this.name = value;
	}
	
	/**
	 * 分类名称
	 */
	@Column(name="name", nullable=true, length=255)	
	public String getName() {
		return name;
	}
	
	/**
	 * 分类图片
	 */
	public void setImage(String value) {
		this.image = value;
	}
	
	/**
	 * 分类图片
	 */
	@Column(name="image", nullable=true, length=255)	
	public String getImage() {
		return image;
	}
	
	/**
	 * 前台显示 0为否 1为是
	 */
	public void setIsShow(byte value) {
		setIsShow(new Byte(value));
	}
	
	/**
	 * 前台显示 0为否 1为是
	 */
	public void setIsShow(Byte value) {
		this.isShow = value;
	}
	
	/**
	 * 前台显示 0为否 1为是
	 */
	@Column(name="isShow", nullable=true)	
	public Byte getIsShow() {
		return isShow;
	}
	
	/**
	 * 排序
	 */
	public void setSort(int value) {
		setSort(new Integer(value));
	}
	
	/**
	 * 排序
	 */
	public void setSort(Integer value) {
		this.sort = value;
	}
	
	/**
	 * 排序
	 */
	@Column(name="sort", nullable=true, length=10)	
	public Integer getSort() {
		return sort;
	}
	
	public void setParent(cn.imvc.app.entities.GoodsClass value) {
		this.parent = value;
	}
	
	@ManyToOne(targetEntity=cn.imvc.app.entities.GoodsClass.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="parentId", referencedColumnName="id", nullable=false) })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public cn.imvc.app.entities.GoodsClass getParent() {
		return parent;
	}
	
	public void setGoods(java.util.Set value) {
		this.goods = value;
	}
	
	@OneToMany(mappedBy="goodsClass", targetEntity=cn.imvc.app.entities.Goods.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getGoods() {
		return goods;
	}
	
	
	public void setGoodsClass(java.util.Set value) {
		this.goodsClass = value;
	}
	
	@OneToMany(mappedBy="parent", targetEntity=cn.imvc.app.entities.GoodsClass.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@OrderBy(value="sort")	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getGoodsClass() {
		return goodsClass;
	}
	
	
	public void setGoodsClassAttr(java.util.Set value) {
		this.goodsClassAttr = value;
	}
	
	@OneToMany(mappedBy="goodsClass", targetEntity=cn.imvc.app.entities.GoodsClassAttr.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getGoodsClassAttr() {
		return goodsClassAttr;
	}
	
	
	public void setBrand_Goods_Class(java.util.Set value) {
		this.brand_Goods_Class = value;
	}
	
	@OneToMany(mappedBy="goodsClass", targetEntity=cn.imvc.app.entities.BrandGoodsClass.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getBrand_Goods_Class() {
		return brand_Goods_Class;
	}
	
	
	public String toString() {
		return toString(false);
	}
	
	public String toString(boolean idOnly) {
		if (idOnly) {
			return String.valueOf(getId());
		}
		else {
			StringBuffer sb = new StringBuffer();
			sb.append("GoodsClass[ ");
			sb.append("Id=").append(getId()).append(" ");
			sb.append("Name=").append(getName()).append(" ");
			sb.append("Image=").append(getImage()).append(" ");
			if (getParent() != null)
				sb.append("Parent.Persist_ID=").append(getParent().toString(true)).append(" ");
			else
				sb.append("Parent=null ");
			sb.append("IsShow=").append(getIsShow()).append(" ");
			sb.append("Sort=").append(getSort()).append(" ");
			sb.append("Goods.size=").append(getGoods().size()).append(" ");
			sb.append("GoodsClass.size=").append(getGoodsClass().size()).append(" ");
			sb.append("GoodsClassAttr.size=").append(getGoodsClassAttr().size()).append(" ");
			sb.append("Brand_Goods_Class.size=").append(getBrand_Goods_Class().size()).append(" ");
			sb.append("]");
			return sb.toString();
		}
	}
	
}
